const mongoose = require("./db");
//创建一个用户schema
const users = new mongoose.Schema({
  name: String,
  password: String,
  email: String,
  phone: Number,
  rid: {
    type: mongoose.Types.ObjectId,
    ref: "role",
  },
});
//创建一个民生服务
const Peopleliveserve = new mongoose.Schema({
  driction: String,
  type: String,
  time: String,
  people: String,
  phone: String,
  address: String,
  inter: String,
  process: String,
  result: String,
  status: String,
  cpeople: String,
});
const PeopleliveserveModel = mongoose.model(
  "peopleliveserve",
  Peopleliveserve,
  "peopleliveserve"
);
//创建一个权限模型
const Menu = new mongoose.Schema({
  path: String,
  label: String,
  mid: String,
});
const MenuModel = mongoose.model("menu", Menu, "menu");
//创建一个角色模型
const Role = new mongoose.Schema({
  name: String,
  // menus:Array,
  mid: {
    type: [mongoose.Types.ObjectId],
    ref: "menu",
  },
});

// 政策法规-类型
const policiesAndRegulationsType = mongoose.Schema({
  name: String, //名称
});
// 政策法规
const policiesAndRegulations = mongoose.Schema({
  title: String, //标题
  content: String, //内容
  time: String, //时间
  // 关联policiesAndRegulationsType
  type: {
    type: mongoose.Types.ObjectId,
    ref: "policiesAndRegulationsType",
  },
  isMyUrl: { type: Boolean, default: true }, //自建链接 | 外部连接
  cover: String, //封面
  author: String, //作者
  isTop: { type: Boolean, default: false }, //是否置顶
  isRecommend: { type: Boolean, default: false }, //是否首页展示
  isCarousel: { type: Boolean, default: false }, //是否轮播
  isShow: { type: Boolean, default: false }, //是否显示
  readingTimes: { type: Number, default: 0 }, //阅读次数
  visibleRange: {
    type: Number,
    default: 0, //可见范围
  },
  // 发布时间
  publishTime: {
    type: Date,
    default: Date.now,
  },
});
//专题教育-类型
const specialEducationType = mongoose.Schema({
  name: String, //名称
});
//专题教育
const specialEducation = mongoose.Schema({
  title: String, //标题
  content: String, //内容
  time: String, //时间
  // 关联specialEducationType
  type: {
    type: mongoose.Types.ObjectId,
    ref: "specialEducationType",
  },
  isMyUrl: Boolean, //自建链接 | 外部连接
  cover: String, //封面
  author: String, //作者
  isTop: { type: Boolean, default: false }, //是否置顶
  isRecommend: { type: Boolean, default: false }, //是否首页展示
  isCarousel: { type: Boolean, default: false }, //是否轮播
  isShow: { type: Boolean, default: false }, //是否显示
  readingTimes: { type: Number, default: 0 }, //阅读次数
  visibleRange: {
    type: Number,
    default: 0, //可见范围
  },
  // 发布时间
  publishTime: {
    type: Date,
    default: Date.now,
  },
});
// 智慧党建 学习管理 试题库类型
const itemBankType = mongoose.Schema({
  name: String, //名称
})

// 智慧党建 学习管理 试题库
const itemBank = new mongoose.Schema({
  title: String, //标题
  type: {  //类型
    type: mongoose.Types.ObjectId,
    ref: "specialEducationType",
  },//类型
  questionTypes: String,//题目类型
  founder: String,//创建人
  publishTime: {  //创建时间
    type: Date,
    default: Date.now,
  },
})
//智慧党建 组织管理  党组织管理
const partymanagement = new mongoose.Schema({
  name: String, //组织名称
  type: String, //组织类型
  superior: {
    type: String,
    default: "无",
  }, //上级组织
  responsibility: {
    type: String,
    default: "无",
  }, //组织职责
  architecture_diagram: {
    type: String,
    default: "无",
  }, //组织架构图
  children: {
    type: Array,
    default: [],
  }, //下级组织
});

//智慧党建 组织管理 领导班子
const leadingbody = new mongoose.Schema({
  name: String, //姓名
  type: String, //类型
  gender: {
    type: String,
    default: "男",
  }, //性别
  phone: {
    type: String,
    default: "13932021341",
  }, //联系电话
  job: String, //职务
  attended_time: {
    type: String,
    default: "周一",
  }, //值班时间
  imgs: {
    type: String,
    default: "无",
  }, //图片
});

//智慧党建 组织管理 党员管理
const partymember = new mongoose.Schema({
  name: String, //姓名
  gender: {
    type: String,
    default: "男",
  }, //性别
  type: String, //类型
  phone: {
    type: String,
    default: "13932021341",
  }, //联系电话
  organization: String, //组织
  nation: {
    type: String,
    default: "汉族",
  }, //民族
  imgs: {
    type: String,
    default: "无",
  }, //图片
  native_place: {
    type: String,
    default: "无",
  }, //籍贯
  education_background: {
    type: String,
    default: "本科",
  }, //学历
  date_of_birth: {
    type: Date,
    default: Date.now,
  }, //出生日期
  party_post: {
    type: String,
    default: "党员",
  }, //党内职务
  tel: {
    type: String,
    default: "18732034718",
  }, //手机号码
  probationary_date: {
    type: Date,
    default: Date.now,
  }, //转为预备党员日期
  full_membership_date: {
    type: Date,
    default: Date.now,
  }, //转为正式党员日期
  address: {
    type: String,
    default: "无",
  }, //住址
  mobile_party_member: {
    type: String,
    default: "否",
  }, //是否流动党员
  outward_flow: {
    type: String,
    default: "否",
  }, //外出流向
  lost_party_member: {
    type: String,
    default: "否",
  }, //是否失联党员
  date_of_loss: {
    type: Date,
    default: Date.now,
  }, //失联日期
  flag: {
    type: Boolean,
    default: false,
  },
});

// birthday表
const xbirthday = mongoose.Schema({
  name: String,
  organization: String,
  intotime: String,
  Pushtime: String,
})

const wang = mongoose.Schema({
  wname: String,

  wdata: {
    type: Date,
    default: Date.now,
  },
  wuser: String,
});
const Birthdaymodel = mongoose.model("xbirthday", xbirthday, "xbirthday");
const User = mongoose.model("user", users, "user");
const RoleModel = mongoose.model("role", Role, "role");
const Wang = mongoose.model("wang", wang, "wang");
const partymanagementModel = mongoose.model(
  "partymanagement",
  partymanagement,
  "partymanagement"
);
const leadingbodyModel = mongoose.model(
  "leadingbody",
  leadingbody,
  "leadingbody"
);
const partymemberModel = mongoose.model(
  "partymember",
  partymember,
  "partymember"
);

const policiesAndRegulationsTypeModel = mongoose.model(
  "policiesAndRegulationsType",
  policiesAndRegulationsType,
  "policiesAndRegulationsType"
);
const policiesAndRegulationsModel = mongoose.model(
  "policiesAndRegulations",
  policiesAndRegulations,
  "policiesAndRegulations"
);
const specialEducationTypeModel = mongoose.model(
  "specialEducationType",
  specialEducationType,
  "specialEducationType"
);
const specialEducationModel = mongoose.model(
  "specialEducation",
  specialEducation,
  "specialEducation"
);
const itemBankModel = mongoose.model("itemBank", itemBank, "itemBank");
const itemBankTypeModel = mongoose.model("itemBankType", itemBankType, "itemBankType");

module.exports = {
  Wang,
  User,
  PeopleliveserveModel,
  MenuModel,
  RoleModel,
  policiesAndRegulationsTypeModel,
  policiesAndRegulationsModel,
  specialEducationTypeModel,
  specialEducationModel,
  itemBankModel,
  itemBankTypeModel,
  partymanagementModel,
  leadingbodyModel,
  partymemberModel,
  PeopleliveserveModel,
  MenuModel,
  RoleModel,
  Birthdaymodel,
}; //导出
